<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');

//页面信息
$_AR['page']=core_setting('site');
$_AR['page']['title']=$_AR['page']['title'] ? $_AR['page']['title']:'进云智能快速开发系统，是一款免费开源的互联网产品开发管理系统！';
$_AR['page']['keywords']=$_AR['page']['keywords']? $_AR['page']['keywords']:'进云系统,微信公众号,手机移动开发,互联网+,模块开发,插件开发';
$_AR['page']['description']=$_AR['page']['description']? $_AR['page']['description']:'进云智能快速开发系统，是一款免费开源的互联网产品开发管理系统，是国内最完善移动网站及移动互联网技术解决方案！';
$_AR['page']['icon']=$_AR['page']['icon']?tomedia($_AR['page']['icon']):'../core/resource/favicon.ico';
$_AR['page']['logo']=$_AR['page']['logo']?tomedia($_AR['page']['logo']):'../core/resource/images/top-logo.png';
$_AR['page']['llogo']=$_AR['page']['llogo']?tomedia($_AR['page']['llogo']):'../core/resource/ng-logo.png';
//整理 main_data
if(!$main_data){
	$main_data=array();
}
if(!$main_data['logo']){
	$main_data['logo']=$_AR['page']['logo'];
}
if(!$main_data['llogo']){
	$main_data['llogo']=$_AR['page']['llogo'];
}
if(!$main_data['kflink']){
	$main_data['kflink']=$_AR['page']['kflink'];
}
if(!$main_data['alipay']){
	$main_data['alipay']=$_AR['page']['alipay'];
}
if(!$main_data['wxpay']){
	$main_data['wxpay']=$_AR['page']['wxpay'];
}
if(!$main_data['ewm']){
	$main_data['ewm']=$_AR['page']['ewm'];
}
if(!$main_data['kfewm']){
	$main_data['kfewm']=$_AR['page']['kfewm'];
}
if(!$main_data['phone']){
	$main_data['phone']=$_AR['page']['phone'];
}
if(!$main_data['qq']){
	$main_data['qq']=$_AR['page']['qq'];
}
if(!$main_data['footerright']){
	$main_data['footerright']=$_AR['page']['footerright'];
}
if(!$main_data['footerleft']){
	$main_data['footerleft']=$_AR['page']['footerleft'];
}
if($_SESSION['uid']){
	if(!$main_data['framess']){
		$framess=core_setting('menu');
		foreach($framess as $key1=>&$menu){
			foreach($menu['child'] as $key2=>&$sub){
				foreach($sub['child'] as $key3=>&$row){
					if(!check_permission($row['plugin'],$row['action'],$row['op'])){
						unset($sub['child'][$key3]);
					}
					if($plugin==$row['plugin'] && $action==$row['action'] && $_RQ['op']==$row['op']){
						$key11=$key1;
					}
				}
				if(!$sub['child']){
					unset($menu['child'][$key2]);
				}
			}
			if(!$menu['child']){
				unset($framess[$key1]);
			}
		}
		$main_data['framess']=$framess;
		$main_data['key1']=$key11?$key11:0;
	}
	if(!$main_data['top_right_menu']){
		$main_data['top_right_menu']=array();
	}
}
$search=html_config($access,$main_data);
$search['page']=$_AR['page'];
$search['isfounder']=$_SESSION['isfounder'];
if($_SESSION['uid']){
	$search['username']=$_SESSION['user']['name'];
}else{
	$search['username']=false;
}
//JSSDK
if ($_SESSION['os'] =='mobile'){
	$wechat_id=pdo_getcolumn('core_account_wechat',array('uniacid'=>1,'isdefault'=>1),'id');
	if(!$wechat_id){
		$wechat_id=pdo_getcolumn('core_account_wechat',array('uniacid'=>1),'id');
	}
	if($wechat_id){
		$search['jssdk']=cfc('account',$wechat_id)->getJssdkConfig();
		$search['jssdk']=json_encode($search['jssdk']);
	}else{
		$search['jssdk']='{}';
	}
	$share=array(
			'title'=>$_AR['page']['title'],
			'desc'=>$_AR['page']['description'] ? $_AR['page']['description'] : $_AR['page']['title'],
			'link'=>$_AR['siteurl'],
			'imgUrl'=>$_AR['page']['logo'] ? SITEROOT.'resource/'.$_AR['page']['logo'] : SITEROOT.'core/resource/images/nopic.jpg',
		);
	$search['share']=ijson_encode($share);
}
$mainsource=ROOT_D . "/{$_SESSION['this']}/templates/{$_AR['template']}/{$_SESSION['os']}/common/main.html";
if(!is_file($mainsource)){
	$mainsource = ROOT_D . "/{$_SESSION['this']}/templates/default/{$_SESSION['os']}/common/main.html";
}
if(!is_file($mainsource)){
	$mainsource = ROOT_D . "/{$_SESSION['this']}/templates/default/windows/common/main.html";
}
if(!is_file($mainsource)){
	$mainsource = ROOT_D . "/{$_SESSION['this']}/templates/default/mobile/common/main.html";
}
if(!is_file($mainsource)){
	exit('error:template source needed is not exist!');
}
if($_GET['csjs']){
	$mainsource = ROOT_D . "/{$_SESSION['this']}/templates/default/windows/common/main1.html";
}
$html=file_get_contents($mainsource);

$js=file_get_contents(ROOT_D.'/core/resource/js/main_manage.js');
$html=str_replace('{js}',$js,$html);
$html=cfc('tools')->replace($search,$html);
echo $html;
access_log();
exit;
?>